'use strict';

const extend = require('extend');


module.exports = mongoose => {

  const MongooseModel = require('./mongoose_model_')(mongoose);

  return class TreeSchemaModel extends MongooseModel {

    constructor(name, schema, indexes) {
      schema = extend({
        pathNode: {
          type: String,
          required: true,
        },
        node: {
          type: String,
          required: true,
        },
        name: {
          type: String,
          required: true,
        },
      }, schema);

      indexes = extend([{
        pathNode: 1,
      }, {
        node: 1,
      }, {
        name: 1,
      } ], indexes);

      super(name, schema, indexes);
    }
  };
};
